package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.News;
import cn.wolfcode.trip.base.query.NewsQueryObject;
import cn.wolfcode.trip.base.service.INewsService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("news")
public class NewsController {
    @Autowired
    private INewsService newsService;

    /**
     * 获取首页日报
     *
     * @param qo
     * @return
     */
    @RequestMapping(value = "/hots", method = RequestMethod.GET)
    public PageInfo queryForHot(NewsQueryObject qo) {
        qo.setOrderBy("releaseTime desc");
        return newsService.queryForHot(qo);
    }

    /**
     * 根据id获取日报详细内容
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public News getById(@PathVariable Long id) {
        return newsService.getById(id);
    }
}
